package server

import (
	"net/http"

	"github.com/google/wire"

	"github.com/gin-gonic/gin"
)

type serverConfig struct {
	ServerName string
	Addr       string
}

type MyServer struct {
	Name   string
	Server http.Server
}

func NewServerConfig() serverConfig {
	return serverConfig{
		ServerName: "app01",
		Addr:       ":8080",
	}
}

func NewHttpServer(config serverConfig) http.Server {
	r := gin.Default()
	return http.Server{
		Addr:    config.Addr,
		Handler: r,
	}
}

func NewMyServer(config serverConfig, server http.Server) *MyServer {
	return &MyServer{
		Name:   config.ServerName,
		Server: server,
	}
}

var MyServerSet = wire.NewSet(NewServerConfig, NewHttpServer, NewMyServer)
